import request from '@/utils/request'

// 添加用户
export function createAddUser(data) {
  return request({
    url: '/authority/auUser/add',
    method: 'post',
    data
  })
}

// 设置二级审核密码
export function setApprovedPass(approvedPassword, password, userPassword) {
  return request({
    url: '/authority/auUser/approved/password',
    method: 'post',
    params: { approvedPassword, password, userPassword }
  })
}

// 用户修改自己的登陆密码
export function updateUserPass(newPassword, oldPassword) {
  return request({
    url: '/authority/auUser/change/password',
    method: 'put',
    params: {
      newPassword, // 新密码
      oldPassword // 旧密码
    }
  })
}

// 获取用户所属公司信息
export function fetchUserCompany(data) {
  return request({
    url: '/authority/auUser/company',
    method: 'get',
    data
  })
}

// 删除用户
export function deleteUser(userId) {
  return request({
    url: '/authority/auUser/delete',
    method: 'delete',
    params: { userId }
  })
}

// 查询用户明细
export function fetchUserDetails(userId) {
  return request({
    url: `/authority/auUser/detail/${userId}`,
    method: 'get',
    params: {}
  })
}

// 查询用户列表
export function fetchUserList(companyId, roleId, userName) {
  return request({
    url: '/authority/auUser/queryList',
    method: 'get',
    params: {
      companyId,
      roleId,
      userName
    }
  })
}

// 改变用户状态
export function statusUser(userId, userStatus) {
  return request({
    url: '/authority/auUser/status',
    method: 'put',
    params: { userId, userStatus }
  })
}

// 验证用户登录名是否唯一
export function uniqueLogin(companyId, userAccount) {
  return request({
    url: '/authority/auUser/unique',
    method: 'get',
    params: { companyId, userAccount }
  })
}

// 修改用户明细
export function updateUser(data) {
  return request({
    url: '/authority/auUser/update',
    method: 'put',
    data
  })
}

